import java.awt.image.BufferedImage;

public class Sprite{
	float speed;
	float currentSpeed;
	float angle;
	int currentImage;
	int updates;
	Key key;
	
	public Sprite(float angle,float speed,Key key)
	{
		if(speed>0){
		this.speed = speed;
		}
		else{
		this.speed = 0;
		}
		this.currentSpeed = speed;
		currentImage = 0;
		this.angle = angle;
		this.key = key;
	}
	public void update()
	{
		updates++;
		if(currentSpeed >0)
		{
			if((31-currentSpeed)-updates <= 0)
			{
				currentImage++;
				updates = 0;
				if(currentImage >(key.getEnd()-key.getStart()))
				{
					currentImage = 0;
				}
			}
		}
	}
	public void reset()
	{
		currentImage = 0;
		updates = 0;
		this.currentSpeed = speed;
	}
	public void stop()
	{
		currentSpeed = 0;
	}
	public void start()
	{
		currentSpeed = speed;
	}
	public void lastImage()
	{
		this.currentImage = key.getEnd()-key.getStart();
	}
	public void setImg(int currentImage)
	{
		this.currentImage = currentImage;
	}
	public int getType()
	{
		return key.getType();
	}
	public int getImg()
	{
		return key.getStart() + currentImage;
	}
	public float getSpeed()
	{
		return speed;
	}
	public void setSpeed(float speed)
	{
		this.currentSpeed = speed;
	}
	public void setAngle(float angle)
	{
		this.angle = angle;
	}
	public float getAngle() {
		return angle;
	}
}
